﻿using Dapper;
using Management.Systeam.Domaina;
using MediatR;
using System.Text;
using Warehouse.Api.Read.AGCation.Command;
using Warehouse.Api.Read.Dtos;
using Warehouse.Domian.Model;
using Warehouse.ErrorCode;
using Warehouse.Infrastructrue.Implenment;

namespace Warehouse.Api.Read.AGCation.Hanlder
{
    public class AccountModelCommandHanlder : IRequestHandler<AccountModelCommand, ApiResult<List<Basicinformatio>>>
    {
        DbContext db;
        ILogger<AccountModelCommandHanlder> logger;

        public AccountModelCommandHanlder(DbContext db, ILogger<AccountModelCommandHanlder> logger)
        {
            this.db = db;
            this.logger = logger;
        }
       /// <summary>
       /// 获取下拉框的方法
       /// </summary>
       /// <param name="request"></param>
       /// <param name="cancellationToken"></param>
       /// <returns></returns>

        public  async Task<ApiResult<List<Basicinformatio>>> Handle(AccountModelCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<Basicinformatio>> result = new ApiResult<List<Basicinformatio>>();
            try
            {
                var sqlBuilder = new StringBuilder();
                sqlBuilder.Append(@"SELECT 
                                      

                                        FROM users WHERE 0=0");
                var sql = await db.DapperConnection.QueryAsync<Basicinformatio>(sqlBuilder.ToString());
                result.Code = ApiEume.Success;
                result.Msg = "获取用户下拉框成功";
                result.Data = sql.ToList();


            }
            catch (Exception ex)
            {

            }
            return result;
        }
    }
}
